//pack11jsclass

var ObjectCardNavigation = new objectCardNavigation();

function objectCardNavigation() {

    this.current=0;
    this.classes=["ObjectCardNavigationInfo","ObjectCardNavigationMap","ObjectCardNavigationImage"];
    this.pages=["ObjectCardInfo","ObjectCardMap","ObjectCardImage"];
    this.mapDone=false;

    this.open = function(element) {
        //alert(element.id);
        elementNumber=element.id.split("CardNavigation");
        pageOpen=document.getElementById(ObjectCardNavigation.getPage(elementNumber[1]));
        pageClose=document.getElementById(ObjectCardNavigation.getPage(ObjectCardNavigation.current));
        document.getElementById("CardNavigation"+ObjectCardNavigation.current).className=ObjectCardNavigation.getClass(ObjectCardNavigation.current);
        pageClose.style.display="none";
        pageOpen.style.display="block";
        pageOpen.style.height="auto";
        ObjectCardNavigation.current=elementNumber[1];
        element.className=(elementNumber[1]>1)? "ObjectCardHighLightImage":"ObjectCardHighLightItem";
        if(elementNumber[1]==1) DekaroMap.init();
        ObjectCardNavigation.setZoomNavigation();
    }

    this.setZoomNavigation = function() {
        if(ZoomPhotoPopup.state()) {
            //alert(ObjectCardNavigation.getPage(ObjectCardNavigation.current)+"_src");
            image=document.getElementById(ObjectCardNavigation.getPage(ObjectCardNavigation.current)+"_src").value;
            ZoomPhotoPopup.newPhoto(image.replace("large", "original"));
            ZoomPhotoPopup.navigation.innerHTML=this.getNavigationContainer().innerHTML;
        }
    }

    this.getNavigationContainer = function() {
        divs=document.getElementById(ObjectCardNavigation.getPage(ObjectCardNavigation.current)).getElementsByTagName("div");
        for(di=0;di<divs.length;di++) {
            if(divs[di].className=="NavigationContainer") {
                return divs[di];
                break;
            }
        }
        return false;
    }

    this.getClass = function(n) {
        if(Number(n)>1) {
            return this.classes[2];
        } else {
            return this.classes[n];
        }
    }

    this.getPage = function(n) {
        if(Number(n)>1) {
            return this.pages[2]+(n-2);
        } else {
            /*if(n==1 && !this.mapDone) {
                this.mapDone=true;
                //DekaroMap.init();
            }*/
            return this.pages[n];
        }
    }

    this.mapLoaded = function() {
        if(this.current!=1) {
            try {
                document.getElementById("ObjectCardMap").style.display="none";
            } catch(e) {
                Trace(e);
            }
        }
    }

    this.nextPhoto = function() {
        nextNumber=Number(ObjectCardNavigation.current)+1;
        try {
            ObjectCardNavigation.open(document.getElementById("CardNavigation"+nextNumber));
        } catch(e) {
            alert(e);
            return false;
        }
    }

    this.previousPhoto = function() {
        nextNumber=Number(ObjectCardNavigation.current)-1;
        try {
            ObjectCardNavigation.open(document.getElementById("CardNavigation"+nextNumber));
        } catch(e) {
            return false;
        }
    }
	
}